package com.zy.edu.bean;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotations.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 
 * </p>
 *
 * @author HuangHaiShui
 * @since 2021-07-13
 */
@Data
public class Jurisdiction implements Serializable {

    private static final long serialVersionUID = 1L;

    private String id;
    /**
     * 辖区名称
     */
    @NotBlank(message = "辖区名称不能为空")
    private String name;

    @TableField("create_time")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    @JSONField(format="yyyy-MM-dd")
    private Date createTime;

    /**
     * 省份代码
     */
    private String province;
    /**
     * 市区代码
     */
    private String city;
    @TableField("province_name")
    private String provinceName;
    @TableField("city_name")
    private String cityName;
    /**
     * 状态：1 在用；2 停用
     */
    @JSONField(serialize = false)
    private Integer status;

    @TableField(exist = false)
    @JSONField(serialize = false)
    private List<School> schoolList;

    public List<School> getChildren(){
        if(this.schoolList==null
                ||this.schoolList.size()==0){
            List<School> list = new ArrayList<>();
            School ci = new School();
            ci.setId("0");
            ci.setName("请选择一个数据");
            list.add(ci);
            return  list;
        }else {
            return this.schoolList;
        }
    }
}
